Crate census

source ·
Expand description

§Census

Census’ Inventory makes it possible to track a set of living items of a specific type. Items are automatically removed from the Inventory<T> as the living item’s are dropped.

use census::{Inventory, TrackedObject};

let inventory = Inventory::new();

//  Each object tracked needs to be registered explicitely in the Inventory.
//  A `TrackedObject<T>` wrapper is then returned.
let one = inventory.track("one".to_string());
let two = inventory.track("two".to_string());

// A snapshot  of the list of living instances can be obtained...
// (no guarantee on their order)
let living_instances: Vec<TrackedObject<String>> = inventory.list();
assert_eq!(living_instances.len(), 2);

Structs§